<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>splice</title>
	</head>
	<body>
		<p id="old"></p>
		<p id="mynew">修改后的数组</p>
		<button onclick="my()">点击</button>
		<script>
			function my(){
				//获取p标签元素对象
				var old=document.getElementById('old');
				var mynew=document.getElementById('mynew');
				//定义数组
				var fruits=["Banana","Orange","Apple","Mango"];
				old.innerHTML=fruits;
				//在Orange元素之后，添加原色：pear、peach
//				fruits.splice(2,0,"pear","peach");
//				mynew.innerHTML=fruits;
				//在Orange元素之后，删除2个元素
				fruits.splice(0,2);
				mynew.innerHTML=fruits;
			}
		</script>
	</body>
</html>
